home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Interactive Web Graphics with Shout 3D
/
Interactive Web Graphics With Shout 3D.iso
/
mac
/
Shout3Ddemo
/
Shout3d_runtime
/
codebase
/
custom_nodes
/
CountDisplay.java
< prev
next >
Wrap
Text File
|
2000-10-19
|
1KB
|
47 lines
package custom_nodes;
import shout3d.core.*;
import shout3d.*;
import java.awt.*;
public class CountDisplay extends PostRenderEffect implements DeviceObserver {
boolean initialized = false;
int count = 0;
Font labelFont = new Font("SansSerif", Font.BOLD, 16);
//constructor
public CountDisplay (){
}
//to handle mouse input
public boolean onDeviceInput(DeviceInput di, Object userData){
MouseInput mi = (MouseInput)di;
switch (mi.which){
case MouseInput.DOWN:
count++;
return true;
}
return false;
}
//called after each render;
//overriden from super class
public void filter(Graphics g, int surface_pixel_bits[], float z_buffer[], int deviceWidth, int deviceHeight){
//register to receive mouse events
if (!initialized) {
getViewer().getDeviceListener().addDeviceObserver(this, "MouseInput", null);
initialized = true;
}
g.setFont(labelFont);
g.setColor(java.awt.Color.red);
String countString = ""+count;
g.drawString(countString, 30, 30);
}
}